package com.bluesky.common.config;

import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 读取项目相关配置
 *
 * @author Kevin
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@Component
@ConfigurationProperties(prefix = "app")
public class AppConfig {
    /**
     * 项目名称
     */
    @Getter
    private static String name;

    /**
     * 版本
     */
    @Getter
    private static String version;

    /**
     * 版权年份
     */
    @Getter
    private static String copyrightYear;

    /**
     * 实例演示开关
     */
    @Getter
    private static boolean demoEnabled;

    /**
     * 工作目录
     */
    @Getter
    private static String profile;

    /**
     * 获取地址开关
     */
    @Getter
    private static boolean addressEnabled;

    /**
     * 缓存前缀
     */
    @Getter
    private static String prefix;

    /**
     * 令牌有效期
     */
    @Getter
    private static Integer expireTime;


    /**
     * 获取临时目录路径
     *
     * @return
     */
    public static String getTemp() {
        return AppConfig.profile + "/temp";
    }

    public void setName(String name) {
        AppConfig.name = name;
    }

    public void setVersion(String version) {
        AppConfig.version = version;
    }

    public void setCopyrightYear(String copyrightYear) {
        AppConfig.copyrightYear = copyrightYear;
    }

    public void setDemoEnabled(boolean demoEnabled) {
        AppConfig.demoEnabled = demoEnabled;
    }

    public void setAddressEnabled(boolean addressEnabled) {
        AppConfig.addressEnabled = addressEnabled;
    }

    public void setProfile(String profile) {
        AppConfig.profile = profile;
    }

    public void setPrefix(String prefix) {
        AppConfig.prefix = prefix;
    }

    public void setExpireTime(Integer expireTime) {
        AppConfig.expireTime = expireTime;
    }

}
